package com.freewater.javabase.demo.record;

public record Point(int x, int y) {

    // Compact Constructor
    public Point {
        if (x < 0) {
            throw new RuntimeException("x 不能为负");
        }
    }

    public static void main(String[] args) {
        Point point = new Point(1, 2);
        System.out.println(point.x() + " " + point.y());
    }
}
